package com.zw.knowlege.controller;

import com.alibaba.fastjson.JSONObject;
import com.zw.common.annotation.InterfaceAttribute;
import com.zw.common.constant.InterfaceNameConstants;
import com.zw.common.response.ResponseResult;
import com.zw.knowlege.annotation.ParamCheckJson;
import com.zw.knowlege.common.StaticValue;
import com.zw.knowlege.service.CollectRecordService;
import com.zw.knowlege.service.ExperienceBaseService;
import com.zw.knowlege.util.CommonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author xtyu
 * @Date 2022/5/10
 * @description 经验信息查询的Controller
 */
@RestController
@RequestMapping("/experiencequery")
public class ExperienceQueryController{

    @Autowired
    private ExperienceBaseService experienceBaseService;

    @Autowired
    private CollectRecordService collectRecordService;

    @PostMapping("/homepageQuery")
    @InterfaceAttribute(name = InterfaceNameConstants.KNOWLEGE_EXPERIENCE_HOMEPAGE, operateType = "4", module = "7")
    public ResponseResult homepageQuery(@RequestBody(required = false) JSONObject paramJson) {
        return ResponseResult.success(experienceBaseService.homepageQueryExperience(paramJson));
    }

    @PostMapping("/myExperience")
    @InterfaceAttribute(name = InterfaceNameConstants.KNOWLEGE_EXPERIENCE_MYSELF, operateType = "4", module = "7")
    @ParamCheckJson(args = {StaticValue.EXPERIENCE_USERINFO_USERID})
    public ResponseResult myExperience(@RequestBody JSONObject paramJson){
        return ResponseResult.success(experienceBaseService.queryMyExperience(paramJson));
    }

    @PostMapping("/myCollectRecord")
    @InterfaceAttribute(name = InterfaceNameConstants.KNOWLEGE_EXPERIENCE_MYCOLLECT, operateType = "4", module = "7")
    @ParamCheckJson(args = {StaticValue.EXPERIENCE_USERINFO_USERID})
    public ResponseResult myCollectRecord(@RequestBody(required = false) JSONObject paramJson){
        return ResponseResult.success(collectRecordService.queryMyCollectExperience(paramJson));
    }

    @PostMapping("/queryExperienceDetails")
    @InterfaceAttribute(name = InterfaceNameConstants.KNOWLEGE_EXPERIENCE_DETAILS, operateType = "4", module = "7")
    @ParamCheckJson(args = {StaticValue.EXPERIENCE_ID, StaticValue.EXPERIENCE_USERINFO_USERID})
    public ResponseResult queryExperienceDetails(@RequestBody JSONObject paramJson){
        return ResponseResult.success(experienceBaseService.queryExperienceDetails(paramJson));
    }

    @GetMapping("/queryDict")
    public ResponseResult queryDict(@RequestParam(required = false) String userid){
        return ResponseResult.success(experienceBaseService.querySelectDict(userid));
    }
}